﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace ODataRegression.Framework.Core.MetaDataOM
{
   public class ODataEntityProperty
    {
       private string name;
       private string type = string.Empty;
       private bool nullable = false;
       private string maxLength = string.Empty;
       private bool unicode = false;
       private bool fixedLength = false;

       public string Name { get {return this.name ;} }
       public string Type { get { return this.type; } }
       public bool Nullable { get { return this.nullable; } }
       public string MaxLength { get { return this.maxLength; } }
       public bool Unicode { get { return this.unicode; } }
       public bool FixedLength { get { return this.fixedLength; } }
       public bool isKey { get { return this.isKey; } }

     public ODataEntityProperty(XElement metadata)
     {
         foreach (XAttribute item in metadata.Attributes())
         {
             switch (item.Name.LocalName)
             {
                 case "Name":
                     {
                         this.name = item.Value;
                         break;
                     }
                 case "Type":
                     {
                         this.type = item.Value;
                         break;
                     }
                 case "Nullable":
                     {
                         this.nullable =Convert.ToBoolean(item.Value);
                         break;
                     }
                 case "MaxLength":
                     {
                         this.maxLength = item.Value;
                         break;
                     }
                 case "Unicode":
                     {
                         this.unicode = Convert.ToBoolean(item.Value);
                         break;
                     }
                 case "FixedLength":
                     {
                         this.fixedLength = Convert.ToBoolean(item.Value); 
                         break;
                     }
                 default:
                     break;
             }
         }
        

     }

    }
}
